Skip to main content

Structured, temporal memory for AI agents.

Project description

memv

memv

/mɛm-viː/ · Structured, temporal memory for AI agents

DocsGetting StartedPyPI

PyPI version Python 3.13+ License: MIT Pydantic AI


Most memory systems extract everything and rely on retrieval to filter it. memv extracts only what the model failed to predict — importance emerges from prediction error, not upfront scoring.

Typical Approach memv
Extract all facts upfront Extract only what we failed to predict
Overwrite old facts Invalidate with temporal bounds
Retrieve by similarity Hybrid vector + BM25 + RRF
Timestamps only Bi-temporal: event time + transaction time

Quick Start

uv add memvee
# or: pip install memvee
from memv import Memory
from memv.embeddings import OpenAIEmbedAdapter
from memv.llm import PydanticAIAdapter

memory = Memory(
    db_url="memory.db",  # or "postgresql://user:pass@host/db"
    embedding_client=OpenAIEmbedAdapter(),
    llm_client=PydanticAIAdapter("openai:gpt-4o-mini"),
)

async with memory:
    await memory.add_exchange(
        user_id="user-123",
        user_message="I just started at Anthropic as a researcher.",
        assistant_message="Congrats! What's your focus area?",
    )

    await memory.process("user-123")

    result = await memory.retrieve("What does the user do?", user_id="user-123")
    print(result.to_prompt())

Features

Predict-Calibrate Extraction · Only extracts what the model failed to predict. Based on Nemori.

Bi-Temporal Validity · Track when facts were true (event time) vs when you learned them (transaction time). Based on Graphiti.

Hybrid Retrieval · Vector similarity + BM25 text search with Reciprocal Rank Fusion.

Episode Segmentation · Groups messages into coherent conversation episodes.

Contradiction Handling · New facts invalidate conflicting old facts. Full audit trail preserved.

SQLite + PostgreSQL · SQLite for local dev, PostgreSQL with pgvector for production. Set db_url to choose between them.

Multiple Embedding Providers · OpenAI, Voyage, Cohere, or local via fastembed. Dimensions detected from the adapter.


Point-in-Time Queries

memv's bi-temporal model lets you query knowledge as of a specific point in time:

from datetime import datetime

# What did we know about user's job in January 2024?
result = await memory.retrieve(
    "Where does user work?",
    user_id="user-123",
    at_time=datetime(2024, 1, 1),
)

# Show full history including superseded facts
result = await memory.retrieve(
    "Where does user work?",
    user_id="user-123",
    include_expired=True,
)

Architecture

Messages → Episodes → Knowledge → Vector Index + Text Index
                                   (sqlite-vec / pgvector)  (FTS5 / tsvector)
  1. Messages buffered until threshold
  2. Segmented into coherent episodes
  3. Predict what episode should contain (given existing KB)
  4. Compare prediction vs actual — extract the gaps
  5. Store with embeddings + temporal bounds

Framework Integration

class MyAgent:
    def __init__(self, memory: Memory):
        self.memory = memory

    async def run(self, user_input: str, user_id: str) -> str:
        context = await self.memory.retrieve(user_input, user_id=user_id)
        response = await self.llm.generate(
            f"{context.to_prompt()}\n\nUser: {user_input}"
        )
        await self.memory.add_exchange(user_id, user_input, response)
        return response

See Examples for PydanticAI, LangGraph, LlamaIndex, CrewAI, and AutoGen integrations.


Documentation


Contributing

git clone https://github.com/vstorm-co/memv.git
cd memv
make install
make all

See CONTRIBUTING.md for details.


MIT — see LICENSE

Built by vstorm

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memvee-0.1.2.tar.gz (48.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

memvee-0.1.2-py3-none-any.whl (72.7 kB view details)

Uploaded Python 3

File details

Details for the file memvee-0.1.2.tar.gz.

File metadata

  • Download URL: memvee-0.1.2.tar.gz
  • Upload date:
  • Size: 48.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memvee-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b2b489999eed55bae612e9efb19e2c69a336784e3a1614a7eafceb2765126c98
MD5 5c9989a1fe00d0d6a8d9d9ea963824f0
BLAKE2b-256 81f858445cd463cbe99b372db068a60a494987254e1f15c96a97b351c15dfaff

See more details on using hashes here.

Provenance

The following attestation bundles were made for memvee-0.1.2.tar.gz:

Publisher: publish.yml on vstorm-co/memv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file memvee-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: memvee-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 72.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for memvee-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7c8819f4b597867848bdd30b1c2e1be79689452132e0269170d63c643f34640a
MD5 01fcbec88d64d08daf67c0edf33bb604
BLAKE2b-256 c069266f78b2c1bb80676facc433d4ab1a74a9a5cabd2f062d119ae75dafa372

See more details on using hashes here.

Provenance

The following attestation bundles were made for memvee-0.1.2-py3-none-any.whl:

Publisher: publish.yml on vstorm-co/memv

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page